﻿namespace Socium.Science {
	static class Doubles {
		public static double Square(this double value) {
			return value * value;
		}

		public static double Sqrt(this double value) {
			return System.Math.Sqrt(value);
		}

		public static double Abs(this double value) {
			return System.Math.Abs(value);
		}

		public static bool SafeEquals(this double x, double y) {
			return (x - y).Abs() <= 1e-7;
		}

		public static bool IsZero(this double value) {
			return value.SafeEquals(0d);
		}

		public static double Cos(this double value) {
			return System.Math.Cos(value);
		}

		public static double Sin(this double value) {
			return System.Math.Sin(value);
		}

		public static double Percents(this double value, double percents) {
			return value * (percents / 100d);
		}
	}
}
